package com.neiquan.secondhand.util;

import java.io.ByteArrayInputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.math.BigDecimal;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

import org.apache.poi.hwpf.extractor.WordExtractor;
import org.apache.poi.poifs.filesystem.DirectoryEntry;
import org.apache.poi.poifs.filesystem.DocumentEntry;
import org.apache.poi.poifs.filesystem.POIFSFileSystem;
import org.apache.poi.xwpf.usermodel.XWPFDocument;



/** 
 * @author zhulang
 * @date 2016-5-7 上午12:39:09 
 * @descript 
 */

public class Test {

	/**
	 * @param args
	 */
	public static void main(String[] args) {
		/*double num = 7.00;
		double currency = 5.6;
		double total = num * currency;
		DecimalFormat df = new DecimalFormat("0");
		df.setRoundingMode(RoundingMode.UP);
		System.out.println(df.format(total));
		System.out.println(df.format(total / currency));*/
		/*String sql = "select * from ("
    			+ "select appointment.*, user.userImg, user.nickName, NULL as Holyland_Name, NULL as Dest_Name, country.Country_Name from `appointment` "
    			+ "left join user on appointment.UserID = user.id "
    			+ "left join country on country.Country_ID = appointment.HolylandID "
    			+ "where appointment.HolylandID = ? and appointment.DestinationType = 2 and appointment.ID < ? and appointment.Status <> 1 "
    			+ "UNION "
    			+ "select appointment.*, user.userImg, user.nickName, NULL as Holyland_Name, destination.Dest_Name, country.Country_Name from `appointment` "
    			+ "left join user on appointment.UserID = user.id "
    			+ "left join destination on destination.Dest_ID = appointment.HolylandID "
    			+ "left join country on country.Country_ID = destination.Country_ID "
    			+ "where country.Country_ID = ? and appointment.DestinationType = 0 and appointment.ID < ? and appointment.Status <> 1 "
    			+ "UNION "
    			+ "select appointment.*, user.userImg, user.nickName, holyland.Holyland_Name, NULL as Dest_Name, country.Country_Name from `appointment` "
    			+ "left join user on appointment.UserID = user.id "
    			+ "left join holyland on appointment.HolylandID = holyland.Holyland_ID "
    			+ "left join country on country.Country_ID = holyland.Country_ID "
    			+ "where country.Country_ID = ? and appointment.DestinationType = 1 and appointment.ID < ? and appointment.Status <> 1 "
    			+ ") as tempResult order by tempResult.ID desc limit ?";*/
		
		/*String sql = "SELECT * FROM (select a2.*,b.destAddr,b.prod,u.userImg,u.nickName from appointment a2 ,user u ," +
		"(select a.id,c.Country_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
		"from appointment a ,country c where a.HolylandID = c.Country_ID and a.DestinationType = 2 UNION " +
		"select a.id,d.Dest_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
		"from appointment a ,destination d where a.HolylandID = d.Dest_ID and a.DestinationType = 0 UNION " +
		"select a.id,h.Holyland_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
		"from appointment a ,holyland h where a.HolylandID = h.Holyland_ID and a.DestinationType = 1 ) b" +
		" where a2.UserID = u.id and a2.id = b.id and a2.status <> 1 ) c LEFT JOIN " +
		"(SELECT la2.id AS likeid,la2.AppointmentID appointid,GROUP_CONCAT(la2. NAME) AS NAME,count(la2.userid) count " +
		"FROM (SELECT la.*, u.nickName AS NAME FROM like_appointment la, USER u WHERE la.UserID = u.id) la2 " +
		"GROUP BY la2.AppointmentID) d ON c.id = d.appointid ";*/
		/*String sql = "insert into `appointment` (`UserID`,`Content`,`HolylandID`,`DestinationType`,`NeedConsultant`,`Language`,`DiveCenterRequirement`,"
			+ "`IsDepartureNow`,`DepartureTime`,`Status`,`PRC_Time`,`Create_Time`,`ShopID`,`ProdID`,`ProdType`,`ShopName`,`ProdName`) "
			+ "values(?,?,?,?,?,?,?,?,?,0,sysdate(),sysdate(),?,?,?,?,?);";*/
		/*String sql = "SELECT * FROM (select a2.*,b.destAddr,b.prod,u.userImg,u.nickName from appointment a2 ,user u ," +
		"(select a.id,c.Country_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
		"from appointment a ,country c where a.HolylandID = c.Country_ID and a.DestinationType = 2 UNION " +
		"select a.id,d.Dest_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
		"from appointment a ,destination d where a.HolylandID = d.Dest_ID and a.DestinationType = 0 UNION " +
		"select a.id,h.Holyland_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
		"from appointment a ,holyland h where a.HolylandID = h.Holyland_ID and a.DestinationType = 1 ) b" +
		" where a2.UserID = u.id and a2.id = b.id and a2.status <> 1 ) c LEFT JOIN " +
		"(SELECT la2.id AS likeid,la2.AppointmentID appointid,GROUP_CONCAT(la2. NAME) AS NAME,count(la2.userid) count " +
		"FROM (SELECT la.*, u.nickName AS NAME FROM like_appointment la, USER u WHERE la.UserID = u.id) la2 " +
		"GROUP BY la2.AppointmentID) d ON c.id = d.appointid ";*/
		/**
		 * 验证SQL
		 */
		/*String sql = "SELECT * FROM (" +
				"select a2.id as appointid,a2.UserID as userID,a2.Content as content,a2.HolylandID as holylandID," +
				"a2.DestinationType as destinationType,a2.NeedConsultant as needConsultant,a2.`Language` as language," +
				"a2.DiveCenterRequirement as diveCenterRequirement,a2.IsDepartureNow as isDepartureNow," +
				"a2.DepartureTime as departureTime,a2.`Status` as status,a2.PRC_Time as prcTime,a2.Create_Time as createTime," +
				"a2.departurePlace as departurePlace,a2.prodID,a2.prodName,a2.prodType,a2.shopID,a2.shopName,a2.recruitNum," +
				"a2.appointStatus,a2.endTime,b.destAddr,b.prod,u.userImg,u.nickName as userName,d.Pic1 as shopPic " +
				"from appointment a2 ,user u ,(select a.id,c.Country_Name as destAddr," +
				"CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod from appointment a ,country c " +
				"where a.HolylandID = c.Country_ID and a.DestinationType = 2 UNION " +
				"select a.id,d.Dest_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
				"from appointment a ,destination d where a.HolylandID = d.Dest_ID and a.DestinationType = 0 UNION " +
				"select a.id,h.Holyland_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod " +
				"from appointment a ,holyland h where a.HolylandID = h.Holyland_ID and a.DestinationType = 1 ) b," +
				"divecenter d where a2.UserID = u.id and a2.id = b.id and a2.status <> 1 and d.Center_ID = a2.shopID ) c" +
				" LEFT JOIN (SELECT la2.AppointmentID newAppid,GROUP_CONCAT(la2. NAME) AS conditionName," +
				"count(la2.userid) as conditionCount FROM (SELECT la.*, u.nickName AS NAME " +
				"FROM like_appointment la, USER u WHERE la.UserID = u.id) la2 GROUP BY la2.AppointmentID) d " +
				"ON c.appointid = d.newAppid order by c.departureTime desc ";*/
		
		/*String sql = "SELECT * FROM ("
			+ "SELECT `COURSE_ID` AS productID,'tb_course' AS productTable, SHOPID as shopID, `PROTYPE` as productType,"
			+ " `PRONAME` as productName, `DESTINATION` as destination, `PRICEUNIT` as priceUnit,"
			+ " `MINPRICE` as minPrice, `MAXPRICE` as maxPrice, `FIRSTPIC` as firstPic,`CREATETIME` as createTime "
			+ "FROM `tb_course` WHERE `PROSTATUS` = 1 and SHOPID = 46 UNION "
			+ "SELECT `PLANS_ID` AS productID, 'tb_plans' AS productTable, SHOPID as shopID, `PROTYPE` as productType,"
			+ " `PRONAME` as productName, `DESTINATION` as destination, `PRICEUNIT` as priceUnit, "
			+ "`MINPRICE` as minPrice, `MAXPRICE` as maxPrice, `FIRSTPIC` as firstPic,`CREATETIME` as createTime "
			+ "FROM `tb_plans` WHERE `PROSTATUS` = 1 and SHOPID = 68 UNION "
			+ "SELECT `SHIP_ID` AS productID, 'tb_ship' AS productTable, SHOPID as shopID, `PROTYPE` as productType,"
			+ " `PRONAME` as productName, `DESTINATION` as destination, `PRICEUNIT` as priceUnit, "
			+ "`MINPRICE` as minPrice, `MAXPRICE` as maxPrice, `FIRSTPIC` as firstPic,`CREATETIME` as createTime "
			+ "FROM `tb_ship` WHERE `PROSTATUS` = 1 and SHOPID = 22) temp_table ORDER BY createTime DESC ";*/
		
		/*String sql = "SELECT * FROM ("
			+ "select a2.id as appointid,a2.UserID as userID,a2.Content as content,a2.HolylandID as holylandID,"
			+ "a2.DestinationType as destinationType,a2.NeedConsultant as needConsultant,a2.`Language` as language,"
			+ "a2.DiveCenterRequirement as diveCenterRequirement,a2.IsDepartureNow as isDepartureNow,"
			+ "a2.DepartureTime as departureTime,a2.`Status` as status,a2.PRC_Time as prcTime,a2.Create_Time as createTime,"
			+ "a2.departurePlace as departurePlace,a2.prodID,a2.prodName,a2.prodType,a2.shopID,a2.shopName,a2.recruitNum,"
			+ "a2.appointStatus,a2.endTime,b.destAddr,b.prod,u.userImg,u.nickName as userName,"
			+ "d.Pic1 as shopPic from appointment a2 ,user u ,("
			+ "select a.id,c.Country_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod"
			+ " from appointment a ,country c where a.HolylandID = c.Country_ID and a.DestinationType = 2 UNION "
			+ "select a.id,d.Dest_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod "
			+ "from appointment a ,destination d where a.HolylandID = d.Dest_ID and a.DestinationType = 0 UNION "
			+ "select a.id,h.Holyland_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod"
			+ " from appointment a ,holyland h where a.HolylandID = h.Holyland_ID and a.DestinationType = 1 ) b,"
			+ "divecenter d where a2.UserID = u.id and a2.id= b.id and a2.status <> 1 and d.Center_ID = a2.shopID"
			+ " and a2.id = 17) c LEFT JOIN (SELECT la2.AppointmentID newAppid,GROUP_CONCAT(la2. NAME) AS conditionName"
			+ ",count(la2.userid) as conditionCount FROM ("
			+ "SELECT la.*, u.nickName AS NAME FROM like_appointment la, USER u WHERE la.UserID = u.id) la2 "
			+ " GROUP BY la2.AppointmentID) d ON c.appointid = d.newAppid order by c.departureTime desc ";*/
		
		//String sql = sqlConvent("", "402881f454db32660154db381abd0003");
		
		/*String sql = "SELECT * FROM (" +
				"select a2.id as appointid,a2.UserID as userID,a2.Content as content,a2.HolylandID as holylandID," +
				"a2.DestinationType as destinationType,a2.NeedConsultant as needConsultant,a2.`Language` as language," +
				"a2.DiveCenterRequirement as diveCenterRequirement,a2.IsDepartureNow as isDepartureNow," +
				"a2.DepartureTime as departureTime,a2.`Status` as status,a2.PRC_Time as prcTime,a2.Create_Time as createTime," +
				"a2.departurePlace as departurePlace,a2.prodID,a2.prodName,a2.prodType,a2.shopID,a2.shopName,a2.recruitNum," +
				"a2.appointStatus,a2.endTime,b.destAddr,b.prod,u.userImg,u.nickName as userName,d.Pic1 as shopPic " +
				"from appointment a2 ,user u ,(select a.id,c.Country_Name as destAddr," +
				"CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod from appointment a ,country c " +
				"where a.HolylandID = c.Country_ID and a.DestinationType = 2 UNION " +
				"select a.id,d.Dest_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod" +
				" from appointment a ,destination d where a.HolylandID = d.Dest_ID and a.DestinationType = 0 UNION " +
				"select a.id,h.Holyland_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod" +
				" from appointment a ,holyland h where a.HolylandID = h.Holyland_ID and a.DestinationType = 1 ) b," +
				"divecenter d where a2.UserID = u.id and a2.id = b.id and a2.status <> 1 and " +
				"d.Center_ID = a2.shopID and a2.UserID = 827) c LEFT JOIN " +
				"(SELECT la2.AppointmentID newAppid,GROUP_CONCAT(la2. NAME) AS conditionName," +
				"count(la2.userid) as conditionCount FROM (SELECT la.*, u.nickName AS NAME " +
				"FROM like_appointment la, USER u WHERE la.UserID = u.id) la2 GROUP BY la2.AppointmentID) d" +
				" ON c.appointid = d.newAppid order by c.departureTime desc ";*/
		
		/*String sql = "SELECT * FROM (" +
				"select a2.id as appointid,a2.UserID as userID,a2.Content as content,a2.HolylandID as holylandID," +
				"a2.DestinationType as destinationType,a2.NeedConsultant as needConsultant,a2.`Language` as language," +
				"a2.DiveCenterRequirement as diveCenterRequirement,a2.IsDepartureNow as isDepartureNow," +
				"a2.DepartureTime as departureTime,a2.`Status` as status,a2.PRC_Time as prcTime,a2.Create_Time as createTime," +
				"a2.departurePlace as departurePlace,a2.prodID,a2.prodName,a2.prodType,a2.shopID,a2.shopName," +
				"a2.recruitNum,a2.appointStatus,a2.endTime,b.destAddr,b.prod,u.userImg,u.nickName as userName," +
				"d.Pic1 as shopPic from appointment a2 ,user u ,(select a.id,c.Country_Name as destAddr," +
				"CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod from appointment a ,country c " +
				"where a.HolylandID = c.Country_ID and a.DestinationType = 2 UNION " +
				"select a.id,d.Dest_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod" +
				" from appointment a ,destination d where a.HolylandID = d.Dest_ID and a.DestinationType = 0 UNION " +
				"select a.id,h.Holyland_Name as destAddr,CONCAT('产品类型:',a.prodType,'  产品名称:',a.prodName) as prod" +
				" from appointment a ,holyland h where a.HolylandID = h.Holyland_ID and a.DestinationType = 1 ) b," +
				"divecenter d where a2.UserID = u.id and a2.id = b.id and a2.status <> 1 and d.Center_ID = a2.shopID) c " +
				"LEFT JOIN (select * from (SELECT la2.UserID newUserId,la2.AppointmentID newAppid," +
				"GROUP_CONCAT(la2. NAME) AS conditionName,count(la2.userid) as conditionCount FROM (" +
				"SELECT la.*, u.nickName AS NAME FROM like_appointment la, USER u WHERE la.UserID = u.id) la2 " +
				"GROUP BY la2.AppointmentID) e where e.newUserId = 820) d " +
				"ON c.appointid = d.newAppid order by c.departureTime desc ";*/
		
		String sql = "select h.Holyland_ID as holyland_ID,h.Country_ID as country_ID,h.Dest_ID as dest_ID," +
				"h.Holyland_Name as holyland_name,h.Holyland_Name_en as holyland_name_en,h.Pic1 as pic," +
				"CONCAT(d.Dest_Name,' ',h.Holyland_Name) as name from holyland h,destination d " +
				"where h.Country_ID = 4 and h.Dest_ID = d.Dest_ID ";
		
		System.out.println(sql+"=======");
		/*int [] a = {12,23,9,24,15,3,18};
		int[] b = selectSort(a);
		System.out.println(b);*/
		/*String total = test.countMoney("62.6",1);
		System.out.println(total+"===计算汇率后的值");
		String num = test.countMoney(total, 2);
		System.out.println(num+"===得到最初值");*/
		try {
			/*String text = readDoc("D:\\产品协议模型.doc");
			boolean b = writeDoc("D:\\result.doc",text);*/
			//testWord();
			//deleteProductWord("课程新增");
		} catch (Exception e) {
			// TODO Auto-generated catch block
			e.printStackTrace();
		}
		//test.countMoney("3000",1);
		/*if ("1500.56".indexOf(".") == -1) {
			System.out.println(1);
		} else {
			System.out.println(2);
		}*/
		/*String value = "1500.0";
		double count = Double.parseDouble(value);
		int a = (int)(count);
		System.out.println(count+"=="+a);*/
		/*Double v1 = 35.6;
		Double v2 = 12.3;
		double mon = sub(v1,v2);
		System.out.println(mon);
		DecimalFormat df = new DecimalFormat("#,###.00");
		System.out.println(df.format(mon));*/
	}
	
	public static String sqlConvent(String holylandId, String proId){
		String sql = "select a.id as appointid,a.UserID as userID,a.Content as content,a.HolylandID as holylandID," +
				"a.DestinationType as destinationType,a.NeedConsultant as needConsultant,a.`Language` as language," +
				"a.DiveCenterRequirement as diveCenterRequirement,a.IsDepartureNow as isDepartureNow," +
				"a.DepartureTime as departureTime,a.`Status` as status,a.PRC_Time as prcTime," +
				"a.Create_Time as createTime,a.departurePlace as departurePlace,a.prodID,a.prodName,a.prodType," +
				"a.shopID,a.shopName,a.recruitNum,a.appointStatus,a.endTime,u.userImg,u.nickName as userName" +
				" from appointment a ,user u where a.userID = u.id ";
		if (holylandId != null && !"".equals(holylandId)) {
			sql += " and (a.holylandID = "+holylandId+" or a.prodID = '"+proId+"' )" ;
		} else {
			sql += " and (a.prodID = '"+proId+"') ";
		}
		return sql;
	}
	
	public static int[] selectSort(int [] a){
		int n = a.length;
		for (int k = 0 ; k < n - 1; k ++) {
			int min = k;
			for(int i = k + 1; i < n; i ++) {
				if (a[i] < a[min]) {
					min = i;
				}
				if (k != min) {
					int tmp = a[k];
					a[k] = a[min];
					a[min] = tmp;
					
				}
			}
		}
		return a;
	}
	
	public static Double sub(Double v1, Double v2) {
	   BigDecimal b1 = new BigDecimal(v1);
	   BigDecimal b2 = new BigDecimal(v2);
	   return new Double(b1.subtract(b2).doubleValue());
	}
	
	/**
	 * 根据价格和汇率计算
	 * @param money 输入金额
	 * @param currency 币种ID
	 * @param type 1代表外币转人民币,2代表人民币转外币
	 * @return
	 */
	public String countMoney(String money,int type) {
		String curr = "0.14";
		String countMoney = "";
		if (type == 1) {
			/*double countM = Double.parseDouble(money) * Double.parseDouble(curr);
			countMoney = String.valueOf(countM);
			if (countMoney.indexOf(".") != -1) {
				DecimalFormat df = new DecimalFormat("0");
				df.setRoundingMode(RoundingMode.UP);
				countMoney = String.valueOf(df.format(Double.parseDouble(countMoney)));
			}*/
			BigDecimal mon = new BigDecimal(money);
			BigDecimal cur = new BigDecimal(curr);
			double countM = mon.multiply(cur).doubleValue();
			countMoney = String.valueOf((int)Math.ceil(countM));
			//int m = Integer.parseInt(mon.multiply(cur).toString());
			//countMoney = mon.multiply(cur).toString();
		}
		System.out.println(countMoney);
		return countMoney;
	}
	
	public static String readDoc(String file) throws Exception {
	    // 创建输入流读取DOC文件
	    FileInputStream in = new FileInputStream(new File(file));
	    WordExtractor extractor = new WordExtractor(in);
	    String text = extractor.getText();
	    System.out.println(text+"==");
	      
	    /*OPCPackage opcPackage = POIXMLDocument.openPackage(doc);
	    POIXMLTextExtractor extractor2 = new XWPFWordExtractor(opcPackage);*/
	    return text;
	}
	
	public static boolean writeDoc(String path, String content) {
	    boolean w = false; 
	    try {
		    byte b[] = content.getBytes("GBK");
	
		    ByteArrayInputStream bais = new ByteArrayInputStream(b); 
	
		    POIFSFileSystem fs = new POIFSFileSystem(); 
		    DirectoryEntry directory = fs.getRoot(); 
	
		    DocumentEntry document = directory.createDocument("WordDocument", bais);
	
		    FileOutputStream ostream = new FileOutputStream(path); 
	
		    fs.writeFilesystem(ostream); 
	
		    bais.close(); 
		    ostream.close(); 

	    } catch (IOException e) { 
	    	e.printStackTrace(); 
	    }
	    return w; 
	}
	
	public static void testWord() throws IOException {
		Map<String, Object> param = new HashMap<String, Object>();
		/*param.put("productName", "泰国普吉岛蓝角俱乐部潜水课程套餐");
		param.put("addrDetail", "印度尼西亚 	巴厘岛   图蓝本");
		param.put("currencyName", "欧元   ERU");
		param.put("shopName", "巴厘岛图蓝本玛塔哈瑞度假村 Matahari Tulamben Resort");
		param.put("swimtContent", "套餐类型  <br> 总天数/住宿天数/潜水次数:3天2晚6潜 <br>房间类型：标准海景房	房间价格：3432	单房补差：1584");
		param.put("payway", "全款");
		param.put("comcode", "金额");
		param.put("comnum", "2000");
		param.put("productIntro", "泰国普吉岛蓝角俱乐部潜水课程套餐的产品简介--------------");
		param.put("productDetail", "泰国普吉岛蓝角俱乐部潜水课程套餐的产品详情==============");
		param.put("priceDescript", "包含费用：国际认证PADI开放水域OW、AOW考证，平静水域基本练习，教练费。\r PIC注册费（潜水证注册费）。\r" +
				"额外费用：接送机（如需安排提早预订）\r 除了船上自助餐，其余饭餐自理。");
		param.put("norent", "提早10天退订退全额，提早5天退70%，提早3天退50%。1-2天没收订金全款");
		param.put("ifClause", "是");*/
		
		/*Map<String,Object> picture = new HashMap<String, Object>();  
		picture.put("width", 100);  
		picture.put("height", 150);  
		picture.put("type", "jpg");  
		//first.put("firstPic", WordUtil.inputStream2ByteArray(new FileInputStream("C:\\Users\\Public\\Pictures\\Sample Pictures\\kaola.jpg"), true));
		picture.put("content", WordUtil.inputStream2ByteArray(new FileInputStream("C:\\Users\\Public\\Pictures\\Sample Pictures\\kaola.jpg"), true)); 
        param.put("firstPic",picture);*/
		//param.put("pictures", WordUtil.inputStream2ByteArray(new FileInputStream("C:\\Users\\Public\\Pictures\\Sample Pictures\\shuimu.jpg"), true));
        
		List<Object> list = new ArrayList<Object>();
		list.add("泰国普吉岛蓝角俱乐部潜水课程套餐");
		list.add("目的地   : 印度尼西亚 	巴厘岛   图蓝本");
		list.add("币种  : 欧元   ERU");
		list.add("潜店名称  : 巴厘岛图蓝本玛塔哈瑞度假村 Matahari Tulamben Resort");
		list.add("套餐类型  <br> 总天数/住宿天数/潜水次数:3天2晚6潜 <br>房间类型：标准海景房	房间价格：3432	单房补差：1584");
		list.add("付款方式  : 全款");
		list.add("佣金 : 金额   2000");
		list.add("产品简介:<br>泰国普吉岛蓝角俱乐部潜水课程套餐的产品简介----");
		list.add("产品详情:<br>泰国普吉岛蓝角俱乐部潜水课程套餐的产品详情===");
		list.add("价格说明:<br>包含费用<br>国际认证PADI开放水域OW、AOW考证，平静水域基本练习，教练费。<br> PIC注册费（潜水证注册费）。<br>" +
				"额外费用：接送机（如需安排提早预订）<br> 除了船上自助餐，其余饭餐自理。");
		// 列表页
		/*list.add("picture,C:\\Users\\Public\\Pictures\\Sample Pictures\\kaola.jpg");
		// 轮播图
		list.add("picture,C:\\Users\\Public\\Pictures\\Sample Pictures\\kaola.jpg,C:\\Users\\Public\\Pictures\\Sample Pictures\\shuimu.jpg");*/
		
		list.add("退订说明：提早10天退订退全额，提早5天退70%，提早3天退50%。1-2天没收订金全款");
		list.add("退订条款框：是");
		
		list.add("列表页 : ");
		Map<String,Object> picture = new HashMap<String, Object>();  
		picture.put("width", 300);
		picture.put("height", 150);
		picture.put("type", "jpg");
		picture.put("count", 1);
		picture.put("content", WordUtil.inputStream2ByteArray(new FileInputStream("C:\\Users\\Public\\Pictures\\Sample Pictures\\kaola.jpg"), true));
		list.add(picture);
		
		list.add("轮播图 : ");
		Map<String,Object> pictures = new HashMap<String, Object>();  
		pictures.put("width", 300);
		pictures.put("height", 150);
		pictures.put("type", "jpg");
		pictures.put("count", 5);
		pictures.put("content", "C:\\Users\\Public\\Pictures\\Sample Pictures\\shuimu.jpg,C:\\Users\\Public\\Pictures\\Sample Pictures\\juhua.jpg" +
				",C:\\Users\\Public\\Pictures\\Sample Pictures\\dengta.jpg,C:\\Users\\Public\\Pictures\\Sample Pictures\\qie.jpg,C:\\Users\\Public\\Pictures\\Sample Pictures\\shamo.jpg");
		list.add(pictures);
		
        XWPFDocument doc = WordUtil.generateWord2(list);
        //CustomXWPFDocument doc = WordUtil.generateWord(param, "D:/产品协议模型.docx");
        FileOutputStream fopts = new FileOutputStream("D:/2.docx");
        doc.write(fopts);
        fopts.close();
	}
	
	public static boolean deleteProductWord(String productName) {
		boolean flag = false;
		String path = "D://" + productName + ".docx";
		File file = new File(path);
		if (file.isFile() && file.exists()) {
			file.delete();
			flag = true;
		}
		return flag;
	}
	

}

